﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using PowerCreator.LMS.Web.Course;
using PowerCreator.LMS.Course.Entity;
using PowerCreator.LMS.Common.Script;


public partial class sysadmin_SystemInfo_FellowManager : PowerCreator.LMS.Web.Base.BasePage
{
    PowerCreator.LMS.Course.DB.TFellowManager objfellow = new PowerCreator.LMS.Course.DB.TFellowManager();
    string search = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitPage();
            BinderRpt(1);
        }
    }

    protected override void InitPage()
    {
        lbl_InfoTitle_FollewManager.Text = GetLanageValueByKey("AddFellow_msg_7", PowerCreator.LMS.Language.LanagetItemType.Page);
        btn_Add.Text = GetLanageValueByKey("btn_AddNew", PowerCreator.LMS.Language.LanagetItemType.Page);
        base.InitPage();
    }
    //绑定Rpt
    private void BinderRpt(int pageIndex)
    {
        DataTable dt = objfellow.Query(search, "fellowID",LMSPageSize, pageIndex).Tables[1];
        rptUser.DataSource = dt;
        rptUser.DataBind();
        PreAspNetPager(AspNetPager1);
    }

    private void BinderPager(string search)
    {
        AspNetPager1.RecordCount = objfellow.Count(search);
        AspNetPager1.PageSize = LMSPageSize;
    }


    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BinderRpt( AspNetPager1.CurrentPageIndex);
    }
    protected void rptUser_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName.ToLower() == "leditor")
        {
            string url = "EditorFellow.aspx?FellowID=" + e.CommandArgument.ToString();
            Script.RedirectURL(url);
        }
        else if (e.CommandName.ToLower() == "ledadd")
        {
            string url = "AddFellow.aspx";
            Script.RedirectURL(url);
        }
        else if (e.CommandName.ToLower() == "ldel")
        {
            //删除

            TFellow vofellow = objfellow.Load(int.Parse(e.CommandArgument.ToString()));

            if (objfellow.Remove(vofellow.FellowID))
            {
                BinderRpt(AspNetPager1.CurrentPageIndex);
            }

        }        
    }
    protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
        {
            LinkButton lbtn_del = (LinkButton)e.Item.FindControl("lnkbtn_del");
            lbtn_del.Attributes.Add("onClick", "javascript:return confirm('确定删除此记录？');");
        }
    }

    protected void btn_Add_Click(object sender, EventArgs e)
    {
        string url = "AddFellow.aspx";
        Script.RedirectURL(url);
    }
}
